package org.example.xmut.qa.adapter.in.web.listener;

import jakarta.annotation.Resource;

import org.example.xmut.qa.adapter.out.persistence.convertor.QaConvertor;
import org.example.xmut.qa.adapter.out.persistence.entity.QaEntity;
import org.example.xmut.qa.adapter.out.persistence.mapper.QaMapper;
import org.example.xmut.qa.service.domain.Qa;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
@RabbitListener(queues = "qaTest")
public class QaListener {
    @Resource
    private QaMapper qaMapper;
    @RabbitHandler
    public void handler(Qa qa){
        QaEntity qaEntity = QaConvertor.toEntity(qa);
        qaMapper.insert(qaEntity);
    }
}
